<!-- 新增空间 ｜ 合铺 -->
<template>
  <div>
    <el-dialog title="绑定商铺" :visible.sync="dialogShow" width="65%" :close-on-click-modal="false" :close-on-press-escape="false" :show-close="true">
      <template v-if="list.length > 0">
        <el-radio v-for="item in list" class="margin-bottom-30" :key="item.primaryKey" v-model="spaceKey" :label="item.primaryKey">{{ item.name }}</el-radio>
      </template>
      <el-empty v-else description="暂无数据"></el-empty>
      <span v-if="list.length > 0" slot="footer" class="dialog-footer">
        <el-button size="small" @click="hideDialog">取 消</el-button>
        <el-button size="small" type="primary" @click="confirmDialog">保 存</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
  import { apiSpaceUpdate, apiShopAdd, apiSpaceAdd, apiShopMerge, apiSpaceCreate } from '../../../../api/building';
  import { dictList } from '../../../../api/common';
  import { requestTips, askDialog } from '../../../../assets/util';
  import { formValid } from '@/lib/utils';

  export default {
    props: {
      sapceList: {
        type: Array,
        default: () => {
          return [];
        },
      },
    },
    data() {
      return {
        dialogShow: false,
        spaceKey: '',
        list:[]
      };
    },

    watch:{
      sapceList:{
        deep:true,
        handler(list){
          this.list = list.filter(item => (!item.positionX || item.positionX == 0))
        }
      }
    },

    methods: {
      hideDialog() {
        this.dialogShow = false;
        this.spaceKey = '';
      },
      confirmDialog() {
        if (!this.spaceKey) {
          this.$message.warning('请选择商铺！');
          return;
        }
        let space = this.list.find(item => item.primaryKey == this.spaceKey);
        console.log(space);
        this.$emit('mountSvg', space);
      },
    },
  };
</script>
<style lang="scss" scoped></style>
